<template>
  <div class="login">
    <el-form :rules="rules" ref="registerForm" :model="registerForm" class="loginContainer">
      <h3 class="loginTitle">注册</h3>
      <el-form-item prop="username">
        <el-input type="text" auto-complete="false" v-model="registerForm.username" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input type="password" auto-complete="false" v-model="registerForm.password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item prop="inpassword">
        <el-input type="password" auto-complete="false" v-model="registerForm.inpassword" placeholder="请再次输入密码"></el-input>
      </el-form-item>
      <el-form-item>
        <span class="logintext" @click="login"><a>前往登录</a></span>
      </el-form-item>
      <el-button type="primary" style="width:100%" @click="goto">注册</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "login",
  data(){
    return{
      /* 注册用户表单信息 */
      registerForm:{
        username:'',
        password:'',
        inpassword:''
      },
      /* 注册用户表单验证规则 */
      rules:{
        username: [{required:true,message:'请输入用户名',trigger:'blur'}],
        password: [{required:true,message:'请输入的密码',trigger:'blur'}],
        inpassword: [{required:true,message:'请再次输入密码',trigger:'blur'}],
      }
    }
  },
  methods:{
    /* 登录组件跳转 */
    login(){
      this.$router.push('/')
    },
    /* 注册用户功能 */
    goto(){
      /* 注册成功的消息弹窗 */
      this.$message({
        message: '恭喜你，注册成功',
        type: 'success'
      });
    }
  }
}
</script>

<style scoped>
.login{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 720px;
  background-image: url("../img/1.jpg");
  background-size: 100%;
}
.loginContainer{
  border-radius: 15px;
  background-clip: padding-box;
  opacity: 0.9;
  width: 350px;
  padding: 15px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}
.loginTitle{
  margin: 0 auto 40px auto;
  text-align: center;
}
.logintext{
  float: right;
  color: #3cd2f5;
  text-decoration-line: none;
  cursor: pointer
}
</style>
